/**
 * 提现记录
 */

import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/common/not_found.dart';
import 'package:cbec_app/pages/my/controller/withdraw_ctr.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class WithDrawLog extends GetView<WithDrawController> {
  const WithDrawLog({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<WithDrawController>(builder: (controller){
      return BasePage(
      title: "提现记录",
      iconType: IconType.back,
      children: [
        Container(
          height: 600.h,
            margin: EdgeInsets.only(top: 10.w),
            color: Colors.white,
            child: controller.withdrawList.isNotEmpty?Tools.getPullRefresh(
                      enablePullDown: true,
                      enablePullUp: controller.hasNextPage,
                      refreshController: controller.baseRefreshCtr,
                      onRefresh: controller.onPageRefresh,
                      onLoading: controller.onPageLoading,
                      child:ListView.builder(
                        itemCount: controller.withdrawList.length,
                        itemBuilder: (context,index){
                          final Map item = controller.withdrawList[index];
                        return WithdrawLogItem(item: item);
                      })
                    ):const NotFound(),
            //   ListView(
            //   children: [
            //     WithdrawLogItem(title: "银行卡", surplus: "12.27", orderSn: "34353423453423", time: "2024-03-14 20:11:23", amount: "17", states: 1,),
            //     WithdrawLogItem(title: "微信", surplus: "12.27", orderSn: "34353423453423", time: "2024-03-14 20:11:23", amount: "17", states: 2,),
            //     WithdrawLogItem(title: "银行卡", surplus: "12.27", orderSn: "34353423453423", time: "2024-03-14 20:11:23", amount: "17", states: 3,),
            //   ],
            // ),
        )
      ],
    );
    });
  }
}


/**
 * 提现记录item
 */
class WithdrawLogItem extends StatelessWidget {
    final Map item;

  const WithdrawLogItem({
    super.key,
     required this.item
    });
    final TextStyle titleStyle = const TextStyle(fontSize: 12,fontWeight: FontWeight.bold,color: Colors.black);
    final TextStyle surplusTitleStyle = const TextStyle(fontSize: 10,fontWeight: FontWeight.bold,color: Colors.black);
    final TextStyle subTitleStyle = const TextStyle(fontSize: 10,fontWeight: FontWeight.w400,color: Color.fromRGBO(153, 153, 153, 1));
    final TextStyle amountTitileStyle = const TextStyle(fontSize: 14,fontWeight: FontWeight.w700,color: Colors.black);

    final TextStyle states1 = const TextStyle(fontSize: 10,fontWeight: FontWeight.w400,color: Color.fromRGBO(77, 153, 255, 1));
    final TextStyle states2 = const TextStyle(fontSize: 10,fontWeight: FontWeight.w400,color: Color.fromRGBO(7, 193, 96, 1));
    final TextStyle states3 = const TextStyle(fontSize: 10,fontWeight: FontWeight.w400,color: Color.fromRGBO(248, 63, 45, 1));

    

  @override
  Widget build(BuildContext context) {
    final String stateText;
    final TextStyle stateColor;

    switch(item['status']){
      case 0:
      //提现中
        stateText = "提现中";
        stateColor = states1;
      break;
      case 1:
        stateText = "提现成功";
        stateColor = states2;
      break;
      case 2:
        stateText = "提现失败";
        stateColor = states3;
      break;
      default:
        stateText = "未知状态";
        stateColor = states1;
    }

    return Container(
      padding: EdgeInsets.all(18.w),
      decoration: bottom_gary_border,
      // height: 90.h,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          //左边是4列的文本
          SizedBox(
            // alignment: Alignment.topLeft,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("提现到银行卡",style: titleStyle,),
                SizedBox(height: 5.h,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [Text("到账后余额:",style: subTitleStyle,), Text("￥${item['money']}",style: surplusTitleStyle,)],
                ),
                SizedBox(height: 5.h,),
                Text("订单编号:${item['sn']}",style: subTitleStyle,),
                SizedBox(height: 5.h,),
                Text(item['cd'],style: subTitleStyle,),
              ],
            ),
          ),
          //右边的数字
          Column(
            children: [
             Text("￥${item['amount']}",style: amountTitileStyle),
             SizedBox(height: 5.h,),
             Text(stateText,style: stateColor,)
            ],
          )
        ],
      ),
    );
  }
}